<template>
	<view class="nav-pt">
		<view class="w-1 grent"></view>
		<!-- 自定义导航栏 -->
		<view class="w-1 mynav">
			<view class="status_bar"></view>
			<view class="w-1 p-r-30 fr-b-c" style="height: 44px; overflow: hidden">
				<view class="c-ff bold fs-36 fm-ali nav_title" @tap="goback">
					<u-icon name="arrow-leftward" class="arrow-leftward"></u-icon>
					{{ type == 1 ? '旧物提现' : '旧物换购' }}
				</view>
			</view>
		</view>
		<view class="content-view">
			<view class="jiuwu-view">
				<view class="jiuwu-view-title">
					<view class="jiuwu-view-title_left">已选旧物</view>
					<view class="jiuwu-view-title_right">
						总价值：¥
						<text class="jiuwu-view-title_right_num">{{ z_price }}</text>
					</view>
				</view>
				<view class="scroll-view-padding-bottom">
					<view class="content-view-list-item" v-for="(item, index) in list">
						<view class="content-view-list-item-item">
							<view class="list-item-top">
								<view class="list-item-top-left">
									{{ item.order_no }}
								</view>
								<view class="list-item-top-right">
									{{ item.createtime_text }}
								</view>
							</view>
							<view class="list-item-min">
								<image :src="baseUrl.cdnurl + item.data.image" class="list-item-min-left" mode="" v-if="item.data.platform == 0"></image>
								<image :src="item.data.image" class="list-item-min-left" mode="" v-else></image>
								<view class="list-item-min-right">
									<view class="list-item-min-right-top">
										{{ item.data.title }}
									</view>
									<view class="list-item-min-right-bottom">
										<view class="list-item-min-right-bottom-left">
											还能卖¥
											<text class="list-item-min-right-bottom-left-text">{{ item.data.price }}</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="choose_view" v-show="type == 2 && goods_info.length <= 0">
				<view class="choose_view_left">
					<text class="choose_view_bixuan">*</text>
					选择换购商品
				</view>
				<view class="choose_view_right" @tap="choose_goods">
					<view class="">未选择</view>
					<u-icon name="arrow-right" class="arrow-right"></u-icon>
				</view>
			</view>
			<view class="xuanzhong" v-show="type == 2 && goods_info.length > 0">
				<view class="xuanzhong_top">
					<view class="xuanzhong_top_left">选择换购商品</view>
					<view class="xuanzhong_top_right" @tap="choose_goods">
						修改
						<u-icon name="arrow-right" class="arrow-right1"></u-icon>
					</view>
				</view>
				<view class="list-item-min" v-for="(item, index) in goods_info">
					<image :src="item.image" class="list-item-min-left" mode="" v-if="item.platform == 1"></image>
					<image :src="baseUrl.cdnurl + item.image" class="list-item-min-left" mode="" v-else></image>
					<view class="list-item-min-right">
						<view class="list-item-min-right-top">
							{{ item.title }}
						</view>
						<view class="list-item-min-right-bottom">
							<view class="list-item-min-right-bottom-left">¥{{ item.price }}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="" v-if="Number(z_price) > 50 &&((!fullayment && type == 1) || type == 2) ">
				<view class="wuliu">
					<view class="faren" style="padding: 36rpx 0">
						<text class="left-t faren_title">
							上传旧物图片
							<text style="color: #f64949">*</text>
						</text>
						<view class="faren_flex">
							<view class="faren_flex_item" v-for="(item, index) in QualificationsImgList">
								<view class="choose_img" @tap="chooseImage">
									<image :src="item" class="choose_img_view" mode=""></image>
								</view>
								<u-icon name="close-circle-fill" class="close-circle-fill" @tap="close_img(index)"></u-icon>
							</view>
							<view class="faren_flex_item">
								<view class="choose_img" @tap="chooseImage">
									<image src="/static/images/user/xiangji.png" class="choose_img_icon" mode=""></image>
									<view class="choose_img_desc">点击拍照/上传</view>
								</view>
							</view>
						</view>
						<view class="faren_flex_right">可上传多图</view>
					</view>
					<view class="choose_view_left">
						<text class="choose_view_bixuan">*</text>
						填写物流单号
					</view>
					<!-- v-for="(item,index) in list" -->
					<input type="text" class="input" placeholder="请输入单号" v-model="LTnumber" />
				</view>
				<view class="dizhi">
					<view class="dizhi_title">旧件回寄地址</view>
					<view class="dizhi_flex font" >
						<view class="dizhi_desc font" >
							{{ buyback.address }} {{buyback.username}} {{buyback.mobile}}
						</view>
						<view class="dizhi_flex_right" @tap="fuzhi(buyback.address+' '+buyback.username+' '+buyback.mobile)">复制</view>
					</view>
				</view>
			</view>
			<view class="iphonex" style="background: #ffffff" v-if="type == 2">
				<view class="w-1 fr-b-c p-r-30" style="height: 104rpx">
					<view class="fr-s-c fm-ali">
						<view class="fr-s-c fm-ali" style="margin-right: 30rpx">
							<text class="c-66 fs-24">可抵</text>
							<view class="fr-s-c fm-ali" style="color: #fa360a; align-items: baseline">
								<text class="fs-24">￥</text>
								<text class="fs-36">{{ z_price }}</text>
							</view>
						</view>
						<text class="c-66 fs-24">合计</text>
						<view class="fr-s-c fm-ali" style="color: #fa360a; align-items: baseline">
							<text class="fs-24">￥</text>
							<text class="fs-36">{{ pay_money }}</text>
						</view>
					</view>
					<view class="fr-c">
						<view class="buy-btn fr-c" @click="jiaohuan">提交订单</view>
					</view>
				</view>
			</view>
			<view class="iphonex" style="background: #ffffff" v-if="type == 1">
				<view class="w-1 fr-b-c p-r-30" style="height: 104rpx">
					<view class="fr-s-c fm-ali">
						<text class="c-66 fs-24">可提现</text>
						<view class="fr-s-c fm-ali" style="color: #fa360a; align-items: baseline">
							<text class="fs-24">￥</text>
							<text class="fs-36">{{ ktx_price }}</text>
						</view>
					</view>
					<view class="fr-c">
						<view class="buy-btn fr-c" @click="jiaohuan">提交订单</view>
					</view>
				</view>
			</view>
		</view>
		<u-popup closeable bgColor="transparent" border-radius="24" v-model="show" mode="bottom">
			<view class="fl-s-c relative w-1" style="padding: 28rpx 32rpx; background: #ffffff; border-radius: 24rpx">
				<text class="c-00 fs-32" style="margin-top: 110rpx; margin-bottom: 80rpx">支付方式</text>
				<view class="w-1 fr-b-c reason-item" v-for="(item, index) in payTypes" :key="index" @click="changeReason(item, index)">
					<view class="fr-s-c">
						<!-- <text :class="'wlIcon-'+ item.type +'-pay'"></text> -->
						<image :src="item.img" class="circle" style="width: 48rpx; height: 48rpx"></image>
						<view class="m-l-20">
							{{ item.name }}
							<view class="yue" v-if="item.type == 'balance'">可用余额：{{ yu_e }}</view>
						</view>
					</view>
					<image
						:src="index == reasonIndex ? '/static/images/shopcar/color_selected.png' : '/static/images/shopcar/noc_not_select.png'"
						style="width: 36rpx; height: 36rpx"
					></image>
				</view>
				<view class="sure-btn fr-c" @click="subOrder">确定</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
import config from '@/utils/base.js';
export default {
	data() {
		return {
			baseUrl: config,
			list: [
				{
					check: false
				},
				{
					check: false
				}
			],
			goods_info: [],
			type: '',
			show: false,
			payTypes: [
				{
					text: '余额支付',
					type: 'balance',
					img: '/static/images/home/balance_pay_icon.png'
				},
				{
					text: '微信支付',
					type: 'wechat',
					img: '/static/images/user/we_icon.png'
				},
				{
					text: '支付宝支付',
					type: 'alipay',
					img: '/static/images/user/ali_icon.png'
				},
				{
					text: '银联',
					type: 'apple',
					img: '/static/images/home/yinlian.png'
				}
			],
			yu_e: '',
			reasonIndex: 0,
			optionData: [],
			default_address: '',
			orderData: '',
			OldStuff_list: [],
			order_list: '',
			token: '',
			LTnumber: '',
			isnocondition: true,
			QualificationsImgList: [],
			msg: '',
			buyback:'',
		};
	},
	onLoad(options) {
		this.list = JSON.parse(decodeURIComponent(options.OldList));
		for (let item of this.list) {
			item.LTnumber = '';
		}
		console.log(this.list, '这是选的旧物');
		this.type = options.type;
		this.$api.post({
			url: '/wanlshop/pay/getBalance',
			success: (res) => {
				console.log(res);
				this.yu_e = res.data;
				this.$store.commit('user/setUserInfo', { money: res });
				// 获取支付列表
				this.getPayment();
			}
		});
		this.loadData();
	},
	onBackPress() {
		uni.removeStorageSync('BuyBack_type');
	},
	mounted() {
		uni.$on('jiuwulistwdd', (res) => {
			console.log(res)
			this.goods_info = res;
			let num = 0;
			for (let item of this.goods_info) {
				num += Number(item.price);
			}
			let mulriple = uni.getStorageSync('mulriple');
			if (num < (Number(mulriple)*1000)*(Number(this.z_price)*1000)/1000000) {
				this.isnocondition = false;
				setTimeout(() => {
					uni.showToast({
						title: '选择商品必须大于2.2倍！',
						icon: 'none'
					});
				}, 100);
			}
		});
	},
	computed: {
		fullayment(){
			let fullayment = true
			this.list.map((item) => {
				if(item.fullayment == 0){
					fullayment = false
				}
			});
			console.log(fullayment)
			return fullayment
		},
		z_price() {
			let num = 0;
			this.list.map((item) => {
				num += parseFloat(item.data.price);
			});
			console.log(num)
			return Number(num).toFixed(2);
		},

		pay_money() {
			let num = 0;
			console.log(this.goods_info);
			for (let item of this.goods_info) {
				console.log(item);
				num += parseFloat(item.price);
			}
			if (this.goods_info.length > 0) {
				num = num -  Number(this.z_price);
			} else {
				num = 0;
			}
			return num.toFixed(2);
		},
		ktx_price(){
			let mulriple = uni.getStorageSync('mulriple');
			let num =(Number(this.z_price)*1000)/(Number(mulriple)*1000)
			return num.toFixed(2)
		}
	},
	methods: {
		fuzhi(res) {
			uni.setClipboardData({
				data: res,
				success: function () {
					uni.showToast({
						title: '复制成功',
						icon: 'none'
					});
				}
			});
		},
		close_img(index) {
			this.QualificationsImgList.splice(index, 1);
		},
		async chooseImage() {
			let t = this;
			//#ifdef APP-PLUS
			let result = await this.$store.dispatch("quanxian/requestPermissions",'WRITE_EXTERNAL_STORAGE')
				console.log(result)
			if (result !== 1) return
			// #endif
			uni.chooseImage({
				count: 1, //默认9
				success: (res) => {
					console.log(res);
					t.uploadImg(res.tempFilePaths[0]);
				}
			  });
		},
		uploadImg(path) {
			let that = this;
			// 上传图片
			that.$api.get({
				url: '/wanlshop/common/uploadData',
				success: (updata) => {
					console.log(updata);
					console.log(updata.data.uploadurl);
					uni.uploadFile({
						url: updata.data.uploadurl, //仅为示例，非真实的接口地址
						filePath: path,
						name: 'file',
						header: {
							token: uni.getStorageSync('wanlshop:user').token || ''
						},
						formData: updata.data.storage == 'local' ? null : updata.data.multipart,
						success: (res) => {
							console.log(res.data);
							let resinfo = JSON.parse(res.data);
							// that.QualificationsImgList.push(resinfo.data.url);
							that.QualificationsImgList.push(resinfo.data.fullurl);
							console.log(that.QualificationsImgList);
						}
					});
					// that.$api.upload({
					// 	url: updata.data.uploadurl,
					// 	filePath: path,
					// 	name: 'file',
					// 	formData: updata.data.storage == 'local' ? null : updata.data.multipart,
					// 	success: (res) => {
					// 		console.log(res)
					// 		let resinfo = JSON.parse(res);
					// 		that.QualificationsImgList.push(resinfo.data.fullurl);
					// 	}
					// });
				}
			});
		},
		async loadData() {
			console.log(this.list);
			for (let i in this.list) {
				let data = {
					goods_id: this.list[i].data.goods_id,
					number: 1,
					sku_id: this.list[i].data.goods_sku_id,
					platform: this.list[i].data.platform
				};
				this.optionData.push(data);
			}
			this.$api.post({
				url: '/wanlshop/order/getOrderGoodsList',
				loadingTip: '加载中',
				data: {
					data: this.optionData
					// platform:this.platform,
				},
				success: (res) => {
					console.log(res);
					this.buyback = res.data.buyback;
					this.token = res.data.token;
					this.orderData = res.data.orderData;
					if (res.data.addressData) {
						this.default_address = res.data.addressData;
					}
				}
			});
		},
		// 改变支付方式
		changeReason(item, index) {
			this.reasonIndex = index;
		},
		goback() {
			uni.navigateBack();
		},
		choose_goods() {
			uni.setStorageSync('BuyBack_type', 2);
			uni.navigateTo({
				url: '/pages/BuyBack/huangou/huangou'
			});
		},
		jiaohuan() {
			
			if (!this.isnocondition) {
				uni.showToast({
					title: '选择商品必须大于2.2倍！',
					icon: 'none'
				});
				return false;
			}
			if (this.type == 2) {
				if (this.goods_info.length <= 0) {
					uni.showToast({
						title: '请选择换购商品',
						icon: 'none'
					});
					return false;
				}
				
				if(this.z_price > 50 && this.type == 2){
					if (this.QualificationsImgList.length <= 0) {
						uni.showToast({
							title: '请上传旧物图片',
							icon: 'none'
						});
						return false;
					}
					if (!this.LTnumber) {
						uni.showToast({
							title: '请填写物流单号',
							icon: 'none'
						});
						return false;
					}
				}
				this.clickSuborder();
			}
			if (this.type == 1) {
				if(!this.fullayment){
					if(this.z_price > 50){
						if (this.QualificationsImgList.length <= 0) {
							uni.showToast({
								title: '请上传旧物图片',
								icon: 'none'
							});
							return false;
						}
						if (!this.LTnumber) {
							uni.showToast({
								title: '请填写物流单号',
								icon: 'none'
							});
							return false;
						}
					}
				}
				this.tixian();
			}
		},
		tixian() {
			let order = {
				//换购的地址
				shop_address:this.list[0].shop_address,
				//物流单号
				tracking_number:this.LTnumber,
				goods_ids: [],
				order_ids: [],
				ids:[],
				original_order_ids: [],
				QualificationsImgList: this.QualificationsImgList
			};
			// console.log(this.list)
			// return
			for (let item of this.list) {
				order.goods_ids.push(item.data.goods_id);
				order.ids.push(item.data.id)
				order.order_ids.push(item.data.order_id);
				// order.shop_address.push(item.shop_address)
				// order.tracking_number.push(item.LTnumber);
				order.original_order_ids.push(item.data.original_order_id);
			}
			// console.log(order);
			// return
			uni.navigateTo({
				url: '/pages/BuyBack/tixian/tixian?order=' + JSON.stringify(order)+'&ktx_price='+this.ktx_price
			});
		},
		getPayment() {
			let method = 'wap';
			// #ifdef APP-PLUS
			method = 'app';
			// #endif
			// #ifdef MP-BAIDU
			method = 'mini';
			// #endif
			// #ifdef MP-WEIXIN
			method = 'miniapp';
			// #endif
			// #ifdef MP-ALIPAY
			method = 'mini';
			// #endif
			// #ifdef MP-QQ
			method = 'mini';
			// #endif
			this.payTypes = [
				{
					name: '余额支付',
					describe: '',
					type: 'balance',
					method: 'balance',
					state: this.isbalance ? true : false, // 是否可用
					select: this.isbalance ? true : false // 是否选中
				}
			];
			// #ifdef H5
			if (this.$jssdk.isWechat()) {
				this.payTypes.push({
					name: '公众号支付',
					describe: '推荐使用公众号支付',
					type: 'wechat',
					method: 'mp',
					state: true,
					select: this.isbalance ? false : true
				});
			} else {
				this.payTypes.push(
					{
						name: '支付宝',
						describe: '',
						type: 'alipay',
						method: method,
						state: true,
						select: false
					},
					{
						name: '微信支付',
						describe: '推荐使用微信支付',
						type: 'wechat',
						method: method,
						state: true,
						select: this.isbalance ? false : true
					}
				);
			}
			// #endif
			// #ifndef H5
			uni.getProvider({
				service: 'payment',
				success: (e) => {
					e.provider.map((value) => {
						if (value == 'alipay') {
							this.payTypes.push({ name: '支付宝', describe: '', type: value, method: method, state: true, select: false });
						} else if (value == 'wxpay') {
							this.payTypes.push({
								name: '微信支付',
								describe: '推荐使用微信支付',
								type: 'wechat',
								method: method,
								state: true,
								select: this.isbalance ? false : true
							});
						} else if (value == 'baidu') {
							this.payTypes.push({ name: '百度收银台', describe: '', type: value, method: method, state: true, select: false });
						} else if (value == 'appleiap') {
							this.payTypes.push({ name: 'Apple支付', describe: '', type: 'apple', method: method, state: true, select: false });
						}
					});
				}
			});
			// #endif
			console.log(this.payTypes);
		},
		// 提交订单
		subOrder() {
			if (!this.order_list) {
				uni.showToast({
					title: this.msg,
					icon: 'none'
				});
				return false;
			}
			if (!this.reasonIndex) {
				var pay_type = 1;
				var pay_to = 0;
			} else {
				var pay_type = 2;
				var pay_to = this.reasonIndex;
			}
			// console.log(this.reasonIndex)
			let data = {
				type: this.payTypes[this.reasonIndex].type,
				method: 'app'
			};
			console.log(data);
			this.wanlPay(data);
		},
		// 支付成功
		paySuccess() {
			// // this.disabled = false;
			// if(this.order_type === 'goods'){
			// 	this.$store.commit('statistics/order', {
			// 		pay: this.$wanlshop.bcsub(this.$store.state.statistics.order.pay, this.payNum),
			// 		delive: this.$wanlshop.bcadd(this.$store.state.statistics.order.delive, this.payNum)
			// 	});
			// }
			uni.showToast({
				title: '支付成功',
				icon: 'none'
			});
			setTimeout(() => {
				uni.redirectTo({
					url: '/pages/BuyBack/record/record'
				});
			}, 1500);
		},
		// 点击提交订单按钮
		clickSuborder() {
			// console.log(this.goods_info,'this.goods_info')
			// console.log(this.list,'this.list')
			// return
			// // let address_id = this.default_address.id;
			// let data = {
			// 		lists: this.goods_info,
			// 		tracking_number: this.LTnumber,
			// 		order_type: 1,
			// 		// address_id: address_id,
			// 		gift:[],
			// 		shop_address: this.list[0].shop_address,
			// 		// shop_id: this.list[0].shop_id,
			// 		// shop_username: 'eee'
			// 	},
			// 	cart = [];
			// this.list.forEach((item, index) => {
			// 	data.gift.push({
			// 		goods_id: item.data.goods_id,
			// 		number: 1,
			// 		sku_id: item.data.goods_sku_id,
			// 		freight_id:'',
			// 		platform: this.list[indexs].data.platform,
			// 		order_id:this.list[index].data.order_id,

			// 	})
			// data.gift.push({
			// 	// shop_id: item.shop_id,
			// 	// remarks: '',
			// 	// products: [],
			// 	// //店铺优惠券和其他 在下追加
			// 	// coupon_id: ''
			// });
			// item.products.forEach((goods, indexs) => {
			// 	console.log(goods, '------');
			// 	// 购物车数据
			// 	cart.push({
			// 		goods_id: goods.id,
			// 		sku_id: goods.sku.id
			// 	});
			// 	// 商品数据
			// 	data.gift[index].products.push({
			// 		goods_id: goods.id,
			// 		number: goods.number,
			// 		sku_id: goods.sku.id,
			// 		freight_id: goods.freight_id,
			// 		platform: this.list[indexs].data.platform,
			// 		order_id:this.list[index].data.order_id

			// 	});
			// });
			// });
			// console.log(this.list)
			// return
			let address_id = this.default_address.id;
			let data = {
				// address_id :address_id,
				// lists: this.goods_info,
				// gift:[],
				// order_type:1,
				lists: this.goods_info,
				gift: [],
				order_type: 1,
				tracking_number: this.LTnumber,
				address_id: address_id,
				QualificationsImgList: this.QualificationsImgList.join(','),
				images: '',
				act: {
					act_available_time: '',
					amount_withdrawal: ''
				},
				coupon_id: '',
				remarks: '',
				is_score: 0
			};
			for (let item of this.list) {
				let data_old = {
					goods_id: item.data.goods_id,
					number: 1,
					sku_id: item.data.goods_sku_id,
					freight_id: '',
					platform: item.data.platform,
					shop_id: item.data.shop_id || '',
					original_order_id: item.data.original_order_id,
					use_invoice:''
				};
				data.gift.push(data_old);
			}
			// console.log(data)
			// return false

			this.$api.post({
				url: '/wanlshop/order/addOrder',
				data: {
					order: data,
					token: this.token
				},
				loadingTip: '提交订单中...',
				success: (res) => {
					if (res.code != 1) {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
						this.msg = res.msg;
						return false;
					}
					console.log(res);
					this.order_list = res.data.list;
					this.token = res.data.token;
					console.log(this.$store.state.statistics.order.pay);
					this.$store.commit('statistics/order', {
						pay: this.$store.state.statistics.order.pay + res.data.list.length,
						whole: this.$store.state.statistics.order.whole + res.data.list.length
					});

					// // 如果使用优惠券全局减去
					// let coupon =  Object.keys(this.couponData).length;
					// if (coupon != 0) {
					// 	this.$store.commit('statistics/dynamic', {
					// 		coupon: this.$store.state.statistics.dynamic.coupon - coupon
					// 	});
					// }
					// 大厂软件，就是这么迷幻
					if (this.cartType == 'cart') {
						this.$store.dispatch('cart/del');
					}
					let sum = 0,
						order_ids = [];
					if (res.data.list.length <= 1) {
						console.log('今这里了');
						this.price = res.data.list[0].price;
						this.order_type = res.data.list[0].type;
						this.order_no = `${res.data.list[0].type == 'groups' ? '拼团' : ''}订单号：${res.data.list[0].order_no}`;
						this.order_pay_no = res.data.list[0].pay_no;
						this.order_id = res.data.list[0].order_id;
					} else {
						console.log('今else里了');
						res.data.list.forEach((item) => {
							sum = this.$wanlshop.bcadd(sum, item.price);
							order_ids.push(item.order_id);
						});
						this.price = sum;
						this.order_id = order_ids;
						this.payNum = res.data.list.length;
						this.order_no = '合并支付 ' + res.data.list.length + '个订单';
					}
					console.log(this.payNum, '-----');
				}
			});
			console.log(data);
			if (this.is_combination) {
				this.reasonIndex = this.reasonIndex == 0 ? 1 : this.reasonIndex;
			}
			console.log(this.reasonIndex);
			this.show = true;
		},
		async wanlPay(data, code = null) {
			this.$api.post({
				url: '/wanlshop/pay/payment',
				data: {
					order_type: this.order_list[0].type,
					type: data.type,
					method: data.method,
					code: code,
					order_id: this.order_list[0].order_id,
					token: this.token
				},
				success: (res) => {
					console.log(res);
					if (res.code != 1) {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
						return false;
					}
					// 余额支付/小程序支付
					switch (data.type) {
						case 'balance':
							console.log(this.$store.state.user.money, this.price);
							this.$store.commit('user/setUserInfo', {
								money: this.$wanlshop.bcsub(this.$store.state.user.money, this.price)
							});
							this.paySuccess();
							break;
						case 'wechat':
							// 微信 H5支付
							if (data.method == 'wap') {
								setTimeout(() => {
									uni.showModal({
										content: '请确认微信支付是否已完成',
										confirmText: '已完成',
										cancelText: '重新支付',
										success: (response) => {
											if (response.confirm) {
												this.paySuccess();
											} else if (response.cancel) {
												this.confirm();
											}
										}
									});
								}, 2000);
								// 异步查询是否支付成功
								window.location.href = res;
								// 微信 APP支付
							} else if (data.method == 'app') {
								uni.requestPayment({
									provider: 'wxpay',
									orderInfo: res.data,
									success: (e) => {
										console.log('success', e);
										this.paySuccess();
									},
									fail: (e) => {
										uni.showModal({
											content: '支付失败,原因为: ' + e.errMsg,
											showCancel: false
										});
									},
									complete: () => {
										// this.disabled = false;
									}
								});
								// 微信 小程序支付
							} else if (data.method == 'miniapp') {
								uni.requestPayment({
									appId: res.appId,
									nonceStr: res.nonceStr,
									package: res.package,
									paySign: res.paySign,
									signType: res.signType,
									timeStamp: res.timeStamp,
									success: (e) => {
										this.paySuccess();
									},
									fail: (e) => {
										uni.showModal({
											content: '支付失败,原因为: ' + e.errMsg,
											showCancel: false
										});
									}
								});
								// 微信 公众平台支付
							} else if (data.method == 'mp') {
								this.$jssdk.wxpay({
									data: res,
									success: (e) => {
										this.paySuccess();
									},
									fail: (err) => {
										if (err.errMsg == 'chooseWXPay:ok') {
											this.$wanlshop.msg('支付成功');
										} else if (err.errMsg == 'chooseWXPay:cancel') {
											this.$wanlshop.msg('支付失败，取消支付');
										} else if (err.errMsg == 'chooseWXPay:fail') {
											this.$wanlshop.msg('支付失败');
										}
									}
								});
							}
							break;
						case 'alipay':
							if (data.method == 'wap') {
								// this.disabled = false;
								if (this.order_type === 'goods') {
									this.$store.commit('statistics/order', {
										pay: this.$wanlshop.bcsub(this.$store.state.statistics.order.pay, this.payNum),
										delive: this.$wanlshop.bcadd(this.$store.state.statistics.order.delive, this.payNum)
									});
								}
								document.write(res);
							} else if (data.method == 'app') {
								uni.requestPayment({
									provider: 'alipay',
									orderInfo: res.data,
									success: (e) => {
										console.log('success', e);
										this.paySuccess();
									},
									fail: (e) => {
										uni.showModal({
											content: '支付失败,原因为: ' + e.errMsg,
											showCancel: false
										});
									},
									complete: () => {
										// this.disabled = false;
									}
								});
							}
							break;
					}
				}
			});
		},

		// 支付回调(提交订单 支付成功后调用)
		afterPay(order_id, pay_to) {
			// pay_to  0 余额 1 微信 2支付宝
			this.$get({
				url: '/Wxapps/payCallBackNotify',
				data: {
					order_id,
					payprice: this.pay_money,
					types: 'mainShop',
					flag: 0,
					fxsid: 0,
					source: 1,
					pay_to
				}
			}).then((res) => {
				uni.showToast({
					title: res.msg,
					mask: true
				});
				setTimeout(() => {
					uni.redirectTo({
						url: '/pages/UserCenter/MyOrders/MyOrders'
					});
				}, 1500);
			});
		}
	}
};
</script>

<style scoped>
.faren {
	width: 100%;
}
.faren_title {
	width: 100%;
}
.faren_flex {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	justify-content: space-between;
}
.faren_flex_item {
	position: relative;
}
.faren_flex_item_title {
	font-size: 24rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: bold;
	color: #000000;
	margin-top: 20rpx;
}
.faren_flex_right {
	font-size: 22rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #000000;
	margin-top: 20rpx;
}
.close-circle-fill {
	font-size: 40rpx;
	position: absolute;
	top: 0;
	right: -20rpx;
	color: #fa360a;
}
.choose_img_icon {
	width: 64rpx;
	height: 64rpx;
	display: block;
	margin: 0 auto;
	position: relative;
	top: 44rpx;
}
.choose_img {
	width: 290rpx;
	height: 194rpx;
	background: #eeeeee;
	border-radius: 16rpx 16rpx 16rpx 16rpx;
	margin-top: 20rpx;
}
.choose_img_view {
	width: 290rpx;
	height: 194rpx;
	border-radius: 16rpx 16rpx 16rpx 16rpx;
}
.choose_img_desc {
	text-align: center;
	margin-top: 54rpx;
	font-size: 22rpx;
	font-family: Source Han Sans CN-Medium, Source Han Sans CN;
	font-weight: 500;
	color: #959595;
}

.reason-item {
	padding: 24rpx 0;
	color: #000000;
	font-size: 28rpx;
	font-family: Alibaba;
}
.yue {
	font-size: 20rpx;
	color: #999999;
}
.sure-btn {
	width: 686rpx;
	height: 100rpx;
	background: linear-gradient(246deg, #fa360a 0%, #fa8c0a 100%);
	box-shadow: 0rpx 6rpx 32rpx 2rpx rgba(250, 74, 20, 0.58);
	border-radius: 50rpx;
	font-size: 32rpx;
	font-family: Alibaba;
	color: #ffffff;
	margin: auto;
	margin-top: 118rpx;
	margin-bottom: 30rpx;
}
/* page {
		background-color: #F7F7F7 !important;
	} */
.nav-pt {
	min-height: 100vh;
	background-color: #f7f7f7 !important;
	padding-bottom: 200rpx;
}
.grent {
	position: fixed;
	left: 0;
	top: 0;
	width: 100vw;
	height: 212rpx;
	/* background-color: #fff; */
}

.arrow-leftward {
	margin-left: 14rpx;
}
.mynav {
	/* background: linear-gradient(180deg, #FA360A 0%, rgba(250, 54, 10, 0) 100%); */
	background-size: 100vh, 520rpx;
	position: fixed;
	left: 0;
	top: 0;
	z-index: 99;
	overflow: hidden;
}
.nav_title {
	color: #000000;
	/* width: 118rpx; */
	height: 42rpx;
}
.content-view {
	margin-top: 42rpx;
	/* padding-bottom: 100rpx; */
}
.jiuwu-view {
	width: 690rpx;
	/* height: 520rpx; */
	background: #ffffff;
	border-radius: 20rpx;
	margin: 0 auto;
	margin-top: 20rpx;
	padding: 30rpx;
	box-sizing: border-box;
}

.jiuwu-view-title {
	font-size: 32rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #000000;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.content-view-list-item:last-child {
	border: 0;
}

.content-view-list-item {
	display: flex;
	align-items: center;
	height: 226rpx;
	border-bottom: 2rpx solid #f4f4f4;
}

.list-item-top {
	width: 100%;
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 24rpx;
	font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #666666;
}

.list-item-min {
	height: 100%;
	display: flex;
	align-items: center;
	margin-top: 30rpx;
}

.list-item-min-left {
	min-width: 116rpx;
	width: 116rpx;
	height: 116rpx;
	border-radius: 12rpx;
	border: 2rpx solid #f4f4f4;
	margin-right: 20rpx;
}

.list-item-min-right-top {
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	overflow: hidden;
	/*! autoprefixer: off */
	-webkit-box-orient: vertical;
	/*! autoprefixer: on */
	word-break: break-all;
	font-size: 32rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: bold;
	color: #333333;
}

.list-item-min-right-bottom {
	display: flex;
	justify-content: space-between;
	margin-top: 12rpx;
}

.list-item-min-right-bottom-right {
	display: flex;
	align-items: center;
}

.list-item-min-right-bottom-left {
	font-size: 24rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #e32d1d;
}

.list-item-min-right-bottom-left-text {
	font-size: 32rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #e32d1d;
}

.list-item-min-right-bottom-right {
	font-size: 26rpx;
	font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #ffffff;
	text-align: center;
	line-height: 52rpx;
}

.list-item-min-right-bottom-right-left {
	width: 144rpx;
	height: 52rpx;
	background: linear-gradient(360deg, #e32c1c 0%, #e46c30 100%);
	border-radius: 24rpx 0rpx 0rpx 24rpx;
}

.list-item-min-right-bottom-right-right {
	width: 144rpx;
	height: 52rpx;
	background: linear-gradient(180deg, #4ecc81 0%, #34b806 100%);
	border-radius: 0rpx 24rpx 24rpx 0rpx;
}

.choose_view {
	width: 690rpx;
	height: 104rpx;
	background: #ffffff;
	border-radius: 20rpx;
	margin: 0 auto;
	margin-top: 20rpx;
}

.choose_view {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0 24rpx;
	box-sizing: border-box;
}

.choose_view_left {
	font-size: 32rpx;
}

.choose_view_bixuan {
	color: #e32d1d;
}

.choose_view_right {
	font-size: 28rpx;
	font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #e32d1d;
	display: flex;
	align-items: center;
}

.arrow-right {
	color: #000000;
	position: relative;
	top: 2rpx;
	margin-left: 14rpx;
}

.wuliu {
	width: 690rpx;
	/* height: 230rpx; */
	background: #ffffff;
	border-radius: 20rpx;
	margin: 0 auto;
	margin-top: 20rpx;
	padding: 30rpx;
	box-sizing: border-box;
}

.input {
	width: 100%;
	height: 82rpx;
	font-size: 28rpx;
	font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #999999;
	padding-left: 12rpx;
	box-sizing: border-box;
	background-color: #f4f4f4;
	border-radius: 12rpx;
	margin-top: 20rpx;
}

.dizhi {
	width: 690rpx;
	height: 204rpx;
	background: #ffffff;
	border-radius: 20rpx;
	margin: 0 auto;
	margin-top: 20rpx;
	padding: 30rpx;
	box-sizing: border-box;
}

.dizhi_flex {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.dizhi_desc {
	max-width: 500rpx;
	font-size: 26rpx;
	font-family: PingFang SC-Regular, PingFang SC;
	font-weight: 400;
	color: #333333;
	margin: 20rpx 0 14rpx 0;
}

.dizhi_title {
	font-size: 26rpx;
	font-family: PingFang SC-Medium, PingFang SC;
	font-weight: 500;
	color: #000000;
}

.font {
	font-size: 26rpx;
	font-family: PingFang SC-Regular, PingFang SC;
	font-weight: 400;
	color: #333333;
}

.dizhi_flex_right {
	color: #e32d1d;
}

.dizhi_flex_left_num {
	margin-left: 24rpx;
}

.btn {
	width: 702rpx;
	height: 96rpx;
	background: linear-gradient(180deg, #e46c30 0%, #e32c1c 100%);
	border-radius: 128rpx;
	margin: 0 auto;
	margin-top: 60rpx;
	font-size: 30rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #ffffff;
	line-height: 96rpx;
	text-align: center;
}

.xuanzhong {
	width: 690rpx;
	/* height: 250rpx; */
	background: #ffffff;
	border-radius: 20rpx;
	margin: 0 auto;
	margin-top: 20rpx;
	margin-bottom: 40rpx;
	padding: 30rpx;
	box-sizing: border-box;
}
.xuanzhong_top {
	display: flex;
	justify-content: space-between;
}
.xuanzhong_top_left {
	font-size: 32rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #000000;
}
.xuanzhong_top_right {
	font-size: 28rpx;
	font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #999999;
}
.arrow-right1 {
	position: relative;
	top: 2rpx;
}
.jiuwu-view-title_right {
	font-size: 24rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #e32d1d;
}
.jiuwu-view-title_right_num {
	font-size: 32rpx;
}
.buy-btn {
	width: 192rpx;
	height: 68rpx;
	background: #fa360a;
	box-shadow: 0rpx 6rpx 3r2px 2rpx rgba(250, 74, 20, 0.58);
	border-radius: 34rpx;
	font-size: 26rpx;
	font-family: Alibaba;
	color: #ffffff;
	margin-left: 14rpx;
}
</style>
